const BaseHost = 'https://mini.jtwsz.cn/'

export default function({
	host = BaseHost,
	url,
	method,
	data = {},
	header = {}
}) {
	return new Promise((resolve, reject) => {
		uni.request({
			url: host + url,
			method,
			data,
			header: Object.assign({
				'Authorization': uni.getStorageSync('token'),
				'Accept': "application/json, text/plain, */*"
			}, header),
			success: (res) => {
				resolve(res.data)
			},
			fail: (err) => {
				uni.showToast({
					icon: "error",
					title: "当前网络较差"
				})
				// 可以在这里进行失败的公共处理
				reject(err)
			}
		})
	})
}